package com.klangner.go.app.rules;

import com.klangner.go.app.strategy.IGoStrategy;
import com.klangner.go.model.Move;

// An abstract class modeling a Player in a game of Go
// It is also a GoGameListener in order to know when
// the opponent has moved

public abstract class Player{

	/** Stone color */
  private int color;
	
  /**
   * Constructor
   * @param color stone color
   */
  public Player(int color) {
  	this.color = color;
  }
  
  /**
   * @return player color
   */
  public int getColor(){
  	return color;
  }

  /**
   * Make move
   * @param goPosition
   */
  public void makeMove(BoardModel goPosition) {
        
  	assert(goPosition != null && game != null);

    Move newMove;

    newMove = move(goPosition);

    assert(newMove != null);

    game.newMove(newMove.getX(), newMove.getY());
  }
    
    
  protected abstract Move move(BoardModel goPosition);

  public void setGame(GoGame game) {
  	this.game = game;
  }

  public abstract void initPlayer();

  protected GoGame game;
  protected IGoStrategy strategy;
}
